Crate jaded_derive

source ·
Expand description

Derive macro for automatically implementing jaded::FromJava for Rust types.

This is provided as a FromJava macro.

Most implementations of FromJava will be very similar and automatically deriving them makes much more sense than writing almost identical impl blocks for every type.

For a ‘simple’ bean style Java class, eg

public class Person implements Serializable {
    private String firstName;
    private String familyName;
    private int age;
}

The rust equivalent can be automatically derived

#[derive(FromJava)]
struct Person {
    firstName: String,
    familyName: String,
    age: i32,
}

To allow both Java and rust to keep to their respective naming conventions, a ‘rename’ feature is available that allows camelCase java fields to be read into snake_case rust fields

#[derive(FromJava)]
#[jaded(rename)]
struct Person {
    first_name: String,
    family_name: String,
    age: i32,
}

Derive Macros

Derive FromJava for custom Rust types